import {StoreOptions} from "vuex"
import {ACCESS_ENUM} from "@/access/accessEnum";
import {UserControllerService} from "../../generated";
// import  http from '@/utils/httpUtils'
//存储用户信息的state对象
// const state = () => ({

// })

// const getters ={}

// const mutations = {
//     //修改用户的方法

// }

// const actions = {

// }


export default {
    namespaced: true,
    actions: {
        async getLoginUser({commit, state}, payload) {
            const res = await UserControllerService.getLoginUserUsingGet();//再次请求后端获取用户登录信息
            commit('updateUser', res.data);
        }
    },
    mutations: {
        //修改用户的方法
        updateUser(state, payload) {
            state.user = payload
        }
    },
    state: {
        //存储用户信息的state对象
        user: {
            userName: '未登录',
            userRole: ACCESS_ENUM.NO_LOGIN
        }
    }

} as StoreOptions<any>;